<template>
  <el-card shadow="never" class="box-card">
    <div slot="header">
      <span style="fontSize: 16px; fontWeight: bold">{{ title }}</span>
    </div>
    <div>
      <component ref="currentPage" :is="currentTabComponent"/>
    </div>
    <div class="check-btns">
      <el-button type="primary" @click="handleGenerate">生成点检表</el-button>
      <el-button type="primary" >返回上一级</el-button>
      <el-button type="primary" icon="el-icon-receiving">保存</el-button>
      <el-button type="primary" >取消</el-button>
    </div>
  </el-card>
</template>

<script>
import { doAdd } from '@/api/checkManagement/checkhistory'
export default {
  name: 'CheckListGenerate',
  components: {
    productionChecklist: () => import('./components/productionChecklist.vue'),
    checkFormList: () => import('./components/checkFormList.vue')
  },
  data() {
    return {
      title: '生成点检表',
      currentTabComponent: 'productionChecklist'
    }
  },
  methods: {
    handleGenerate() {
      // this.$refs.currentPage.submitForm().then(res => {
      //   console.log(res)
      // })
      doAdd(this.$clearNull(this.$refs.currentPage.searchForm)).then(res => {
        this.title = '点检表'
        this.currentTabComponent = 'checkFormList'
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.box-card{
  width: 80%;
  margin: 40px auto;
  .check-btns{
    display: flex;
    justify-content: flex-end;
  }
}
</style>
